<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <title>foldertree Demo</title>
  <script src="https://cdn.bootcss.com/vue/2.6.10/vue.min.js"></script>
  <script src="https://cdn.bootcss.com/element-ui/2.10.1/index.js"></script>
  <link href="https://cdn.bootcss.com/element-ui/2.10.1/theme-chalk/index.css" rel="stylesheet">
  <style>
    .el-scrollbar__wrap {
      width: 200px;
      height: 600px;
    }
  </style>
</head>
<body>
<div id="app">
  <div class="treeM">
    <el-scrollbar style="display: inline-block">
      <el-tree
        style="display: inline-block;min-width: 13vw"
        :expand-on-click-node="false"
        :props="defaultProps"
        ref="tree"
        @node-expand="nodeExpand"
        :data="data">
      </el-tree>
    </el-scrollbar>
  </div>
</div>
<script>
  new Vue({
    el: '#app',
    data() {
      return {
        data: [{
          label: '一级 1',
          children: [
            {
              label: '二级1111111111111111111111111111111111111111111111111',
              children: []
            },
            {
              label: '二级1',
              children: []
            },
            {
              label: '二级2',
              children: []
            },
            {
              label: '二级2',
              children: []
            },
            {
              label: '二级1',
              children: []
            },
            {
              label: '二级1',
              children: []
            },
            {
              label: '二级2',
              children: []
            },
            {
              label: '二级1',
              children: []
            },
            {
              label: '二级2',
              children: []
            },
            {
              label: '二级2',
              children: []
            },
            {
              label: '二级1',
              children: []
            },
            {
              label: '二级1',
              children: []
            },
            {
              label: '二级2',
              children: []
            },
            {
              label: '二级1',
              children: []
            },
            {
              label: '二级2',
              children: []
            },
            {
              label: '二级2',
              children: []
            },
            {
              label: '二级1',
              children: []
            },
            {
              label: '二级1',
              children: []
            },
            {
              label: '二级2',
              children: []
            },
            {
              label: '二级1',
              children: []
            },
            {
              label: '二级2',
              children: []
            },
            {
              label: '二级2',
              children: []
            },
            {
              label: '二级1',
              children: []
            },
            {
              label: '二级1',
              children: []
            },
            {
              label: '二级2',
              children: []
            },
            {
              label: '二级1',
              children: []
            },
            {
              label: '二级2',
              children: []
            },
            {
              label: '二级2',
              children: []
            },
            {
              label: '二级1',
              children: []
            },
            {
              label: '二级1',
              children: []
            },
            {
              label: '二级2',
              children: []
            },
            {
              label: '二级1',
              children: []
            },
            {
              label: '二级2',
              children: []
            },
            {
              label: '二级2',
              children: []
            },
            {
              label: '二级1',
              children: []
            },
            {
              label: '二级1',
              children: []
            },
            {
              label: '二级2',
              children: []
            }
          ]
        }],
        defaultProps: {
          children: 'children',
          label: 'label'
        }
      }
    },
    methods: {
      nodeExpand(data, node) {
        this.$refs.tree.append({label: '2', children: []}, node)
        console.log(node)
      }
    },
  })
</script>
</body>

</html>
